package org.veridiandynamics.client.view;

import java.awt.CardLayout;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

/**
 * @author Talia
 * 
 * This panel displays patient health history using a JFreeChart object. 
 * 
 */
@SuppressWarnings("serial")
public class PatientHealthHistory extends JPanel {

	private CardLayout c1;
	private JPanel basePanel;
	private JButton back;

	
	/**
	 * Constructor for panel. Creates panel.
	 * @param c1
	 * @param basePanel
	 */
	public PatientHealthHistory(final CardLayout c1, final JPanel basePanel) {
		this.c1 = c1;
		this.basePanel = basePanel;
		
		back = new JButton("Back");
		back.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				c1.show(basePanel, "BASECARD");
			}
		});
		add(back);
		XYSeries series = new XYSeries("Patient Weight versus Time Graph");
		series.add(1,1);
		series.add(2,10);
		XYSeriesCollection dataset = new XYSeriesCollection();
		dataset.addSeries(series);
		JFreeChart chart = ChartFactory.createXYLineChart("Patient Time versus Weight Graph", "Month, Year", "Weight (pounds)", dataset, PlotOrientation.VERTICAL, true, true, false);
		ChartFrame frame = new ChartFrame("Patient History", chart); 
		frame.pack();
		frame.setVisible(true);
	}	

}
